#!/bin/sh
#需要安装jemalloc 5.1.0及以上版本
#LD_PRELOAD="/usr/lib64/libjemalloc.so.2"
#export LD_PRELOAD

#JAVA_HOME="/use/Java/jdk1.8.0_92"
#export JAVA_HOME

JAVA_OPTS="-server -showversion -Xms256m -Xmx512m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m"
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
JAVA_OPTS="$JAVA_OPTS -d64 -XX:CICompilerCount=8 -XX:+UseCompressedOops"
JAVA_OPTS="$JAVA_OPTS -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90"
JAVA_OPTS="$JAVA_OPTS -XX:ReservedCodeCacheSize=128m -XX:-UseAdaptiveSizePolicy"
JAVA_OPTS="$JAVA_OPTS -Duser.timezone=Asia/Shanghai -XX:-DontCompileHugeMethods"
JAVA_OPTS="$JAVA_OPTS -Xss512k -XX:+AggressiveOpts -XX:+UseBiasedLocking"
#MaxTenuringThreshold=15,尽量保存对象内存在Xmn
JAVA_OPTS="$JAVA_OPTS -XX:MaxTenuringThreshold=15 -XX:+CMSParallelRemarkEnabled"
JAVA_OPTS="$JAVA_OPTS -XX:+UseFastAccessorMethods"
JAVA_OPTS="$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true"
JAVA_OPTS="$JAVA_OPTS -XX:+UseGCOverheadLimit -XX:AllocatePrefetchDistance=256 -XX:AllocatePrefetchStyle=1"
#JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:MaxGCPauseMillis=200"
JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC -XX:+UseStringDeduplication -XX:InitiatingHeapOccupancyPercent=45"
JAVA_OPTS="$JAVA_OPTS -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=200"

JAVA_OPTS="$JAVA_OPTS -Ddruid.mysql.usePingMethod=false -Ddruid.registerToSysProperty=true"

#处理log4j2漏洞
JAVA_OPTS="$JAVA_OPTS -Dlog4j2.formatMsgNoLookups=true"

#sentinel配置
JAVA_OPTS="$JAVA_OPTS -Dserver.port=8858"
JAVA_OPTS="$JAVA_OPTS -Dcsp.sentinel.dashboard.server=localhost:8858"
JAVA_OPTS="$JAVA_OPTS -Dproject.name=sentinel-dashboard"
JAVA_OPTS="$JAVA_OPTS -Dsentinel.dashboard.auth.username=sentinel"
JAVA_OPTS="$JAVA_OPTS -Dsentinel.dashboard.auth.password=sentinel"

#输出到当前目录下的nohup.out
nohup java $JAVA_OPTS -jar /opt/sentinel/jar/sentinel-dashboard-1.8.8.jar >> /opt/logs/sentinel-dashboard-1.8.8.log.out

#如果需要输出到docker logs可以用，但是会需要注意，这个命令会一直运行
#tail -f /opt/logs/sentinel-dashboard-1.8.2.log.out
#不输出日志，保持运行状态
tail -F /opt/logs/null
